<?php

namespace Common\Model;

use Think\Model;

/**
 * Description of DealerApplyModel
 * 
 * @author zhangzhen
 * @date 2017-01-03
 */
class DealerApplyModel extends BaseModel {

    protected $trueTableName = 'tb_dealer_apply';

    protected function _before_insert(&$data, $options) {
        // parent::_before_insert($data, $options);
    }

    protected function _before_update(&$data, $options) {
        //parent::_before_update($data, $options);
    }

    /**
     * 手机号返回客栈申请数据(未处理、已处理条件结果)
     * @modify zhangzhen 2017-01-03
     * @param string $mobile  手机号
     * @return type
     */
    public function getInfoByMobile($mobile, $areaCode = '86') {
        $where = array(
            'mobile' => $mobile,
            'areacode' => $areaCode,
            'status' => array('in', array(0, 1))
        );
        return $this->where($where)->find();
    }

    /**
     * 添加申请数据
     * @modify zhangzhen 2017-01-03
     * @modify wenhui 2017-05-22 添加区号
     * @param string $mobile 客栈名称
     * @param string $name 城市名称
     * @param string $idcard 手机号
     * @param string $idcardpath 用户
     * @param string $areaCode 用户
     * @return type
     */
    public function addInfo($mobile, $name, $idcard, $idcardpath, $remark = null, $areaCode = '86') {
        $options = array(
            'mobile' => $mobile,
            'name' => $name,
            'idcard' => $idcard,
            'idcardpath' => $idcardpath,
            'remark' => $remark ? $remark : '',
            'areacode' => $areaCode,
        );
        return $this->add($options);
    }

}
